﻿EvaluationStack = function (methodState) {
    this.methodState = methodState;
    this.entries = [];
};

EvaluationStack.prototype.Push = function (slot) {
    this.entries.push(slot);
    this.methodState.vm.onStackChanged();
};

EvaluationStack.prototype.Pop = function () {
    var retVal = this.entries.pop();
    this.methodState.vm.onStackChanged();
    return retVal;
};

EvaluationStack.prototype.Top = function () {
    if (this.entries.length == 0) return null;

    var topSlot = this.entries[this.entries.length - 1];
    var slotCopy = new StackEntry();
    slotCopy.Type = topSlot.Type;
    slotCopy.Value = topSlot.Value;
    return slotCopy;
};

EvaluationStack.prototype.IsEmpty = function () {
    return this.entries.length == 0;
};

EvaluationStack.prototype.GetSize = function () {
    return this.entries.length;
};